using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Polymod.Tests
{
    [TestClass]
    public class ModelBuildingTests
    {
        public class MyDomainClass
        {
            public int A { get; set; }
            public int B { get; set; }
            public string C;
        }

        [TestMethod]
        public void ShouldBuildModel()
        {
            var factory = CreateFactory();
            var domain = new MyDomainClass() { A = 10, B = 89, C = "Hello" };
            var o = factory.GetModel(domain);
            Assert.AreEqual(10, o.Get("A"));
            Assert.AreEqual(89, o.Get("B"));
            Assert.AreEqual("Hello", o.Get("C"));
        }

        [TestMethod]
        public void ShouldSetValuesOnModel()
        {
            var factory = CreateFactory();
            var domain = new MyDomainClass() { A = 10, B = 89, C = "Hello" };
            var o = factory.GetModel(domain);
            o.Set("A", 8);
            o.Set("B", 78);
            o.Set("C", "Bye");

            Assert.AreEqual(8, domain.A);
            Assert.AreEqual(78, domain.B);
            Assert.AreEqual("Bye", domain.C);
        }

        private ModelFactory CreateFactory()
        {
            return new ModelFactory(new TemplateBuilders.ModelTreeTemplateBuilder());
        }

    }
}
